/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: ZhongJinTao
 * Date: 2024-04-11
 * Time: 20:35
 */
public class Test1 {
    public static void main(String[] args) {
        //幸运数字
        int num = 1;
        int count = 0;
        while (true) {
            if(check(num,2) && check(num, 8) && check(num, 10) && check(num, 16)) {
                count++;
            }
            if(count == 2023) {
                System.out.println(num);
                break;
            }
            num++;
        }
    }
    public static boolean check(int num, int base) {
        int tmp = 0;
        int x = num;
        while (x > 0) {
             tmp += x % base;
             x /= base;
        }
        return num % tmp == 0;
    }

    public static void main1(String[] args) {
        //阶乘求和
        long ans = 1;
        long sum = 0;
        long mod = (long) 1e9;
        int count = 1;
        for(int i = 1; i < 100; i++) {
            ans = (ans * i) % mod;
            sum = sum + ans;
            sum = sum % mod;
            System.out.println(sum + " " + ans + " " + count++);
        }
    }
}
